﻿using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using MyFloridaHouse.DataAccess.Extensions;
using MyFloridaHouse.libSvDTO;

namespace MyFloridaHouse.DataAccess
{
    public partial class DAL_CensusData
    {

        /// <summary>
        /// Gets the layers.
        /// </summary>
        /// <returns>list of <see cref="LayerDTO"/></returns>
        /// <remarks>SPROC: usp_moGetLayers</remarks>
        public List<LayerDTO> GetLayers()
        {
            List<LayerDTO> itemList = new List<LayerDTO>();

            //string storedProcedureName = "usp_moGetLayers";
            string storedProcedureName = "usp_tl10GetLayers10";

            SqlConnection db = Connect();
            SqlCommand StoredProcedureCommand = new SqlCommand(storedProcedureName, db);
            StoredProcedureCommand.CommandType = CommandType.StoredProcedure;
            db.Open();
            using (SqlDataReader rdr = StoredProcedureCommand.ExecuteReader())
            {
                while (rdr.Read())
                {
                    itemList.Add(LayerDTODataContract.DataContract(rdr));
                }
            }

            //Todo:UndoPDFKludge:  temp fix for PDF print 
            // need to add isDisplayLayer to Data contract
            foreach (var item in itemList)
            {
                item.isDisplayLayer = true;
            }

            var expressways = new LayerDTO
            {
                layerid = 25,
                prefix = "tl10hwy10",
                layername = "highways",
                layerabbr = "HWY",
                defaultstrokecolor = "BROWN",
                defaultfillcolor = "TRANSPARENT",
                isBuildLayer = false,
                isDisplayLayer = false
            };
            itemList.Add(expressways);

            var highways = new LayerDTO
            {
                layerid = 26,
                prefix = "tl10Expressways10",
                layername = "expressways",
                layerabbr = "EXPWY",
                defaultstrokecolor = "TOMATO",
                defaultfillcolor = "TRANSPARENT",
                isBuildLayer = false,
                isDisplayLayer = false
            };
            itemList.Add(highways);

            var shorelines = new LayerDTO
            {
                layerid = 27,
                prefix = "tl10shoreline10",
                layername = "shorelines",
                layerabbr = "SHRLN",
                defaultstrokecolor = "DARKBLUE",
                defaultfillcolor = "TRANSPARENT",
                isBuildLayer = false,
                isDisplayLayer = false
            };
            itemList.Add(shorelines);

            return itemList;
        }
    }
}
